home *** CD-ROM | disk | FTP | other *** search
/ DarkBasic Professional / DarkBasicPro.iso / data1.cab / Lang_Files_(English) / Projects / Planet_Potter / progress / Planet Potter 4.dba < prev   
Encoding:
Text File  |  2004-09-22  |  3.9 KB  |  182 lines

  1. Rem Project: Planet Potter
  2. Rem Created: 25/07/2002 15:38:30
  3.  
  4. rem Initialise
  5. sync on : sync rate 60 : hide mouse
  6. set text font "Arial" : set text size 20
  7. set text to bold : set text transparent
  8.  
  9. rem Load environment
  10. load object "media\moonlit\ml.x",100
  11. scale object 100,20,20,20
  12. set object cull 100,0
  13. set object light 100,0
  14. set object texture 100,2,1
  15.  
  16. rem Load nine planets
  17. for p=1 to 9
  18.  load object "media\planet\planet.x",p
  19.  position object p,(p-3)*350,0,500
  20.  hide object p
  21. next p
  22.  
  23. rem Load tenth planet for home
  24. load object "media\planet\planet.x",10
  25. position object 10,0,-150,-350
  26. rotate object 10,0,0,90
  27.  
  28. rem Load particle image
  29. load image "media\gfx\fire.bmp",1
  30.  
  31. rem Load player sounds
  32. load sound "media\sounds\shoot.wav",1
  33.  
  34. rem Load game sounds
  35. load sound "media\sounds\appear.wav",11
  36. for s=12 to 19 : clone sound s,11 : next s
  37. load sound "media\sounds\explode.wav",21
  38. for s=22 to 29 : clone sound s,21 : next s
  39.  
  40. rem Setup camera and light
  41. set camera range 0.1,3000
  42. set point light 0,-50,80,-600
  43. set light range 0,2000
  44.  
  45. rem Main Loop
  46. do
  47.  
  48. rem Get ready prompt
  49. center text screen width()/2,screen height()/2,"GET READY!" : sync
  50. sleep 3000 : show mouse
  51.  
  52. rem Starting states
  53. randomize timer()
  54. energy=100 : prate=100
  55. points=0
  56.  
  57. rem Game loop
  58. gameover=0
  59. while gameover=0
  60.  
  61. rem Control player cursor and shot
  62. if mouseclick()=1 and guncool=-1
  63.  rem Shoot effect
  64.  play sound 1 : guncool=3
  65.  rem Detect good hit
  66.  for p=1 to 9
  67.   if object visible(p)=1 and object angle z(p)=0
  68.    sx=object screen x(p)
  69.    sy=object screen y(p)
  70.    mx=mousex() : my=mousey()
  71.    if mx>sx-100 and mx<sx+100 and my>sy-100 and my<sy+100
  72.     zrotate object p,1
  73.     play sound 20+p
  74.     inc points,10
  75.    endif
  76.   endif
  77.  next p
  78. endif
  79. if guncool=0 and mouseclick()=0 then guncool=-1
  80. if guncool>0 then dec guncool
  81.  
  82. rem Control planets
  83. gosub _newplanets
  84. gosub _moveplanets
  85.  
  86. rem Rotate sky backdrop and home planet
  87. yrotate object 100,wrapvalue(object angle y(100)+0.1)
  88. yrotate object 10,wrapvalue(object angle y(10)-0.05)
  89.  
  90. rem Stats
  91. prompt$="SCORE: "+str$(points)
  92. box 40,screen height()-20,41+(energy*3),screen height()-40,0,0,rgb(255,0,0),rgb(255,0,0)
  93. center text screen width()-text width(prompt$),screen height()-40,prompt$
  94.  
  95. rem Update screen
  96. sync
  97.  
  98. rem End loop
  99. endwhile
  100.  
  101. rem High score prompt
  102. hide mouse
  103. center text screen width()/2,screen height()/2,"YOUR SCORE : "+str$(points) : sync
  104. sleep 3000
  105.  
  106. rem Reset objects
  107. for p=1 to 9
  108.  hide object p
  109. next p
  110.  
  111. rem Main endloop
  112. loop
  113. end
  114.  
  115. _newplanets:
  116.  
  117. if pmaker>0 then dec pmaker
  118. if pmaker=0
  119.  p=1 : while object visible(p)=1 and p<9 : inc p : endwhile
  120.  ssx=1000+(prate*10.0)
  121.  ssy=1000+(prate*5.0)
  122.  x=rnd(ssx)-(ssx/2)
  123.  y=rnd(ssy)-(ssy/2)
  124.  position object p,x,y,1000
  125.  scale object p,100,100,100
  126.  rotate object p,0,0,0
  127.  ghost object off p
  128.  play sound 10+p
  129.  show object p
  130.  pmaker=prate+rnd(prate/2)
  131.  if prate>15 then dec prate,5
  132. endif
  133.  
  134. return
  135.  
  136. _moveplanets:
  137.  
  138. rem Move all planets
  139. for p=1 to 9
  140.  `
  141.  if object visible(p)=1 and object angle z(p)=0
  142.   `
  143.   rem Move planet
  144.   sp#=25-(prate/10.0)
  145.   position object p,object position x(p)/1.01,(object position y(p)-1)/1.01,object position z(p)-sp#
  146.   yrotate object p,wrapvalue(object angle y(p)+1)
  147.   if object position z(p)<-600 then hide object p
  148.   `
  149.   rem Detect when hit home planet
  150.   dx#=abs(object position x(p)-object position x(10))
  151.   dy#=abs(object position y(p)-object position y(10))
  152.   dz#=abs(object position z(p)-object position z(10))
  153.   dist#=sqrt((dx#*dx#)+(dy#*dy#)+(dz#*dz#))
  154.   if dist#<300
  155.     zrotate object p,1
  156.     play sound 20+p
  157.     energy=energy-20
  158.     if energy<=0 then gameover=1
  159.   endif
  160.   `
  161.  endif
  162.  `
  163. next p
  164.  
  165. rem Handle planet destruction
  166. for p=1 to 9
  167.  if object angle z(p)>0 and object visible(p)=1
  168.   s=50-object angle z(p)
  169.   ghost object on p,2
  170.   scale object p,s*2,s*2,s*2
  171.   zrotate object p,object angle z(p)+1
  172.   if object angle z(p)>70
  173.    hide object p
  174.   endif
  175.  endif
  176. next p
  177.  
  178. return
  179.  
  180.  
  181.  
  182.